package com.jihu.design.behavioral.memento;

import org.apache.commons.beanutils.BeanUtils;

import java.lang.reflect.InvocationTargetException;
import java.util.HashMap;
import java.util.Map;

/**
 * @author jihu
 * @date 2021/10/8
 */
public class GameServer {

    Map<Integer,GameRecord> records = new HashMap<>();

    int i = 1;

    void add(GameRecord gameRecord){
        records.put(i++,gameRecord);
    }

    LeiGamer getRecord(Integer id) throws Exception {
        GameRecord record = records.get(id);
        //获取到备忘录里面的内容还要逆转
        LeiGamer leiGamer = new LeiGamer();
        BeanUtils.copyProperties(leiGamer,record);
        return leiGamer;
    }
}
